<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=path%>/css/manager/password.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<%=path%>/js/manager/jquery-1.8.2.js"></script>
<title>修改管理员密码</title>
</head>
<body>
   	<input type="hidden" id="sysuserId"  value="${back_user.sysuserId}"/>
   	<input type="hidden" id="sysuserName"  value="${back_user.sysuserName}"/>
		<div class="pass">
			<div class="pass_div1">修改密码</div>
			<div class="pass_div2" id="content"></div>
			<input class="pass_in1" type="password" placeholder="原密码" id="oldpwd" value=""/>
			<input class="pass_in2" type="password" placeholder="新密码" id="newpwd"  value=""/>
			<input class="pass_in3" type="password" placeholder="确认密码" id="surepwd"  value=""/>
			<input class="pass_in4" type="button" value="修改密码" onclick="changePwd()"/>
			<div class="pass_div3">Web app framework base on Bootstrap and AngularJS© 2014</div>
		</div> 
</body>
<script type="text/javascript">
//修改密码
function changePwd(){
	//验证管理员登录
	var sysuserId=$("#sysuserId").val();
	if(sysuserId.length==0){
		alert("管理员登录失效，请重新登录");
		window.open("<%=path%>/login/beforelogin.htm");
		return false;
	}
	
	var oldpwd=$("#oldpwd").val();
	var newpwd=$("#newpwd").val();
	var surepwd=$("#surepwd").val();
	if(oldpwd.length==0){
		$("#content").html("请输入原密码！");
		$("#oldpwd").focus();
		return false;
	}else if(newpwd.length==0){
		$("#content").html("请输入新密码！");
		$("#newpwd").focus();
		return false;
	}else if(newpwd==oldpwd){
		$("#content").html("新密码不能和原密码一样！");
		$("#newpwd").focus();
		return false;
	}else if(surepwd.length==0){
		$("#content").html("请输入确认密码！");
		$("#surepwd").focus();
		return false;
	}else if(surepwd!=newpwd){
		$("#content").html("两次密码不一致！");
		$("#surepwd").focus();
		return false;
	}
	var sysuserName=$("#sysuserName").val();
	if(window.confirm("确定要修改"+sysuserName+"管理员的登录密码吗？")){
		$.ajax({
			 type : "post",
			 url : '<%=path%>/login/updatpwd.htm',
				data : {
					oldpwd : oldpwd,
					sysuserId : sysuserId,
					sysuserPwd : newpwd
				},
				async : false,
				dataType : 'json',
				success : function(data) {
					 if(data.state==1){
						 alert("修改密码成功");
						 window.open("<%=path%>/login/logout.htm");
					 }else{
						 alert(data.value);
					 }
				},
				error : function(err) {
					alert('网络故障');
				}
			}); 
     }else{
    	 return false;
    	 }
	
}

</script>
</html>